home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_edit.arc / POPUP.C < prev    next >
C/C++ Source or Header  |  1991-09-08  |  848b  |  65 lines

  1.  
  2. #include <stdio.h>
  3. #include <mcega.h>
  4.  
  5. int *open_popup(x2,y2)
  6.   int  x2,y2;
  7. {
  8.   extern int  gdcur_x,gdcur_y;
  9.  
  10.   int  x1,y1,x3,y3,i;
  11.  
  12.   register int *sp;
  13.  
  14.   x1 = gdcur_x;
  15.   y1 = gdcur_y;
  16.  
  17.   if (x1 > x2)
  18.     {
  19.     i = x2;
  20.     x2 = x1;
  21.     x1 = x2;
  22.     }
  23.  
  24.   if (y1 > y2)
  25.     {
  26.     i = y2;
  27.     y2 = y1;
  28.     y1 = y2;
  29.     }
  30.  
  31.   x3 = (x2-x1) + 1;
  32.   y3 = (y2-y1) + 1;
  33.  
  34.   if ((sp = (int *)calloc(x3 * y3 + (sizeof(unsigned int) * 4), 1)) == 0)
  35.     {
  36.     gpterm();
  37.     abort("Out of memory");
  38.     }
  39.  
  40.   sp[0] = x1;
  41.   sp[1] = y1;
  42.   sp[2] = x3;
  43.   sp[3] = y3;
  44.  
  45.   gpmove(x1,y1);
  46.   gpmovgtm(&sp[4],x3,y3,x3);
  47.  
  48.   gpcolor(0);
  49.   gpbox(x2,y2);
  50.  
  51.   gpcolor(1);
  52.   gprect(x2,y2);
  53.  
  54.   return(sp);
  55. }
  56.  
  57. void close_popup(sp)
  58.   int *sp;
  59. {
  60.   gpmove(sp[0],sp[1]);
  61.   gpmovmtg(&sp[4],sp[2],sp[3],sp[2]);
  62.  
  63.   free(sp);
  64. }
  65.